package limeirafol.gui.Cadastro;

import java.awt.event.KeyEvent;
import java.util.Vector;
import javax.swing.SwingConstants;
import limeirafol.Global;
import org.openide.util.Exceptions;
import limeirafol.remote.cadastro.AcessorioFiltroConsultaVO;
import limeirafol.remote.cadastro.AcessorioVO;
import limeirafol.bean.BeanCadastro;
import limeirafol.remote.cadastro.tipoEmbalagem;
import lbframework.bean.internalFrame.LBInternalFrame;
import lbframework.bean.mdiFrame.LBMdiFrame;
import lbframework.bean.table.LBColumnTable;
import lbframework.classe.Util;
import lbframework.classe.LBException;
import lbframework.remote.ItemComboVO;
import limeirafol.remote.Formulario;
import limeirafol.remote.TipoOperacao;

public class AcessorioConsultaGUI extends LBInternalFrame {

    private Vector<AcessorioVO> vAcessorio = null;
    public BeanCadastro beanCadastro = new BeanCadastro();

    /** Creates new form AcessorioConsulta */
    public AcessorioConsultaGUI(LBMdiFrame i_mdiFrame) throws Exception {
        super(i_mdiFrame);

        initComponents();
        centralizarForm();
        this.setMaximum(true);


        cboSituacao.setTabela("situacaocadastro");
        cboSituacao.carregar();
        cboSituacao.addItem(new ItemComboVO(-1, "TODOS"));

        cboTipoAcessorio.setTabela("tipoacessorio");
        cboTipoAcessorio.carregar();
        cboTipoAcessorio.addItem(new ItemComboVO(-1, "TODOS"));
        cboTipoAcessorio.setId(-1);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        vRPanel1 = new lbframework.bean.panel.LBPanel();
        vRLabel1 = new lbframework.bean.label.LBLabel();
        txtDescricao = new lbframework.bean.textField.LBTextField();
        vRLabel2 = new lbframework.bean.label.LBLabel();
        cboSituacao = new lbframework.bean.comboBox.LBComboBox();
        vRLabel3 = new lbframework.bean.label.LBLabel();
        txtCodigo = new lbframework.bean.textField.LBTextField();
        vRLabel4 = new lbframework.bean.label.LBLabel();
        txtCodigoInterno = new lbframework.bean.textField.LBTextField();
        vRLabel5 = new lbframework.bean.label.LBLabel();
        txtCodigoExterno = new lbframework.bean.textField.LBTextField();
        cboTipoAcessorio = new lbframework.bean.comboBox.LBComboBox();
        vRLabel6 = new lbframework.bean.label.LBLabel();
        tblConsulta = new lbframework.bean.tableEx.LBTableEx();
        vRPanel2 = new lbframework.bean.panel.LBPanel();
        vRButton1 = new lbframework.bean.button.LBButton();
        vRButton2 = new lbframework.bean.button.LBButton();
        vRToolBarPadrao1 = new lbframework.bean.toolBarPadrao.LBToolBarPadrao(this);

        setTitle("Acessório Consulta");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/anel.png"))); // NOI18N

        vRLabel1.setText("Descrição");

        vRLabel2.setText("Ativo");

        vRLabel3.setText("Código");

        vRLabel4.setText("Código Interno");

        vRLabel5.setText("Código Externo");

        vRLabel6.setText("Tipo Acessorio");

        javax.swing.GroupLayout vRPanel1Layout = new javax.swing.GroupLayout(vRPanel1);
        vRPanel1.setLayout(vRPanel1Layout);
        vRPanel1Layout.setHorizontalGroup(
            vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(vRLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtCodigoInterno, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(vRLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtCodigoExterno, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(vRLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(vRLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(vRLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboTipoAcessorio, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(vRLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cboSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        vRPanel1Layout.setVerticalGroup(
            vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(vRPanel1Layout.createSequentialGroup()
                        .addComponent(vRLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cboTipoAcessorio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(vRPanel1Layout.createSequentialGroup()
                            .addComponent(vRLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(cboSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(vRPanel1Layout.createSequentialGroup()
                                .addComponent(vRLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(vRPanel1Layout.createSequentialGroup()
                                .addComponent(vRLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtCodigoExterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(vRPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(vRPanel1Layout.createSequentialGroup()
                                    .addComponent(vRLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtCodigoInterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(vRPanel1Layout.createSequentialGroup()
                                    .addComponent(vRLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tblConsulta.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblConsultaMouseClicked(evt);
            }
        });
        tblConsulta.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                tblConsultaKeyPressed(evt);
            }
        });

        vRButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/sair.png"))); // NOI18N
        vRButton1.setText("Sair");
        vRButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton1ActionPerformed(evt);
            }
        });

        vRButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/lbframework/img/consultar.png"))); // NOI18N
        vRButton2.setText("Consultar");
        vRButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                vRButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout vRPanel2Layout = new javax.swing.GroupLayout(vRPanel2);
        vRPanel2.setLayout(vRPanel2Layout);
        vRPanel2Layout.setHorizontalGroup(
            vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, vRPanel2Layout.createSequentialGroup()
                .addContainerGap(545, Short.MAX_VALUE)
                .addComponent(vRButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(vRButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        vRPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {vRButton1, vRButton2});

        vRPanel2Layout.setVerticalGroup(
            vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(vRPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(vRButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(vRButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        vRToolBarPadrao1.setRollover(true);
        vRToolBarPadrao1.setVisibleConsultar(true);
        vRToolBarPadrao1.setVisibleEditar(true);
        vRToolBarPadrao1.setVisibleExcluir(true);
        vRToolBarPadrao1.setVisibleImprimir(true);
        vRToolBarPadrao1.setVisibleIncluir(true);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(vRPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(tblConsulta, javax.swing.GroupLayout.DEFAULT_SIZE, 775, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(vRPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(vRToolBarPadrao1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(vRToolBarPadrao1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addComponent(vRPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(tblConsulta, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(vRPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void vRButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton1ActionPerformed

        try {
            sair();
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        }
    }//GEN-LAST:event_vRButton1ActionPerformed

    private void vRButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vRButton2ActionPerformed
        try {
            consultar();
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        }


    }//GEN-LAST:event_vRButton2ActionPerformed

    private void tblConsultaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblConsultaMouseClicked
        try {
            if (evt.getClickCount() == 2) {
                carregarAcessorio();
            }

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }

    }//GEN-LAST:event_tblConsultaMouseClicked

    private void tblConsultaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tblConsultaKeyPressed

        try {
            if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
                carregarAcessorio();
            }

            if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
                excluir();
            }

        } catch (Exception ex) {
            Util.exibirMensagemErro(ex, getTitle());
        }


    }//GEN-LAST:event_tblConsultaKeyPressed

    @Override
    public void excluir() throws Exception {
        Global.verificarPermissao(Formulario.ACESSORIOS, TipoOperacao.EXCLUIR);
        if (tblConsulta.getLinhaSelecionada() == -1) {
            throw new LBException(Util.MSG_NENHUM_ITEM_SELECIONADO);
        }

        Util.exibirMensagemConfirmar(Util.MSG_CONFIRMA_EXCLUSAO, getTitle());

        AcessorioVO oAcessorio = vAcessorio.get(tblConsulta.getLinhaSelecionada());

        beanCadastro.excluirAcessorio(oAcessorio.id);

        vAcessorio.remove(oAcessorio);

        exibirConsulta();
    }

    private void carregarAcessorio() throws Exception {
        if (tblConsulta.getLinhaSelecionada() == -1) {
            throw new LBException(Util.MSG_NENHUM_ITEM_SELECIONADO);
        }
        AcessorioVO oAcessorio = vAcessorio.get(tblConsulta.getLinhaSelecionada());

        if (consultaCampo == null) {
            AcessorioCadastroGUI form = new AcessorioCadastroGUI(mdiFrame);

            form.carregarAcessorio(oAcessorio.id);
            form.setVisible(true);

        } else {
            this.setVisible(false);

            consultaCampo.setParentSelected(true);
            consultaCampo.setId(oAcessorio.id);
            consultaCampo.consultar(true);
            consultaCampo.transferFocus();
        }
    }

    @Override
    public void consultar() throws Exception {
        Global.verificarPermissao(Formulario.ACESSORIOS, TipoOperacao.CONSULTAR);

        AcessorioFiltroConsultaVO oFiltro = new AcessorioFiltroConsultaVO();
        oFiltro.id = txtCodigo.getInt();
        oFiltro.codigoInterno = txtCodigoInterno.getText();
        oFiltro.codigoExterno = txtCodigoExterno.getText();
        oFiltro.descricao = txtDescricao.getText();
        oFiltro.id_tipoacessorio = cboTipoAcessorio.getId();
        oFiltro.id_situacaoCadastro = cboSituacao.getId();

        vAcessorio = beanCadastro.consultarAcessorio(oFiltro);

        exibirConsulta();
    }

    @Override
    public void incluir() throws Exception {
        Global.verificarPermissao(Formulario.ACESSORIOS, TipoOperacao.INCLUIR);
        AcessorioCadastroGUI form = new AcessorioCadastroGUI(mdiFrame);

        form.incluir();
        form.setVisible(true);

    }

    @Override
    public void editar() throws Exception {
        Global.verificarPermissao(Formulario.ACESSORIOS, TipoOperacao.ALTERAR);
        carregarAcessorio();
    }

    @Override
    public void imprimir() throws Exception {
        Global.verificarPermissao(Formulario.ACESSORIOS, TipoOperacao.IMPRIMIR);
        Global.imprimir("acessorios.jasper", vAcessorio, null);

    }

    private void exibirConsulta() throws Exception {
        LBColumnTable[] colunas = new LBColumnTable[]{
            new LBColumnTable("Código", 60, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Codigo Interno", 100, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Descricao", 200, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Codigo Externo", 100, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Fornecedor", 200, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Estoque Minimo", 100, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Estoque Maximo", 100, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Tipo Embalagem", 90, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Peso (Un.)", 80, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Preco (Un.) / KG", 90, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Tipo Acessorio", 150, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Foto", 50, true, SwingConstants.LEFT, false, null),
            new LBColumnTable("Situação", 100, true, SwingConstants.LEFT, false, null)
        };
        Object[][] dados = new Object[vAcessorio.size()][colunas.length];
        int i = 0;
        for (AcessorioVO oAcessorio : vAcessorio) {
            dados[i][0] = Util.formatNumber(oAcessorio.id, 6);
            dados[i][1] = oAcessorio.codigoInterno;
            dados[i][2] = oAcessorio.descricao;
            dados[i][3] = oAcessorio.codigoExterno;
            dados[i][4] = oAcessorio.fornecedor;

            if (!(oAcessorio.id_tipoEmbalagem == tipoEmbalagem.KG.getId())) {
                dados[i][5] = Util.formatDecimal0(oAcessorio.estoqueMinimo);
                dados[i][6] = Util.formatDecimal0(oAcessorio.estoqueMaximo);
            } else {
                dados[i][5] = Util.formatDecimal3(oAcessorio.estoqueMinimo) + " Kg";
                dados[i][6] = Util.formatDecimal3(oAcessorio.estoqueMaximo) + " Kg";
            }


            dados[i][7] = oAcessorio.tipoEmbalagem;
            dados[i][8] = Util.formatDecimal1(oAcessorio.pesoUnitario) + " g";

            if (!(oAcessorio.id_tipoEmbalagem == tipoEmbalagem.KG.getId())) {
                dados[i][9] = Util.formatDecimal3(oAcessorio.custoUnitario);
            } else {
                dados[i][9] = Util.formatDecimal2(oAcessorio.custoUnitario);

            }

            dados[i][10] = oAcessorio.tipoAcessorio;

            if (!(oAcessorio.foto.equals("SEM_FOTO.JPG"))) {
                dados[i][11] = true;
            } else {
                dados[i][11] = false;
            }
            dados[i][12] = oAcessorio.situacaoCadastro;

            i++;
        }

        tblConsulta.setModel(dados, colunas);

        tblConsulta.requestFocus();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private lbframework.bean.comboBox.LBComboBox cboSituacao;
    private lbframework.bean.comboBox.LBComboBox cboTipoAcessorio;
    private lbframework.bean.tableEx.LBTableEx tblConsulta;
    private lbframework.bean.textField.LBTextField txtCodigo;
    private lbframework.bean.textField.LBTextField txtCodigoExterno;
    private lbframework.bean.textField.LBTextField txtCodigoInterno;
    private lbframework.bean.textField.LBTextField txtDescricao;
    private lbframework.bean.button.LBButton vRButton1;
    private lbframework.bean.button.LBButton vRButton2;
    private lbframework.bean.label.LBLabel vRLabel1;
    private lbframework.bean.label.LBLabel vRLabel2;
    private lbframework.bean.label.LBLabel vRLabel3;
    private lbframework.bean.label.LBLabel vRLabel4;
    private lbframework.bean.label.LBLabel vRLabel5;
    private lbframework.bean.label.LBLabel vRLabel6;
    private lbframework.bean.panel.LBPanel vRPanel1;
    private lbframework.bean.panel.LBPanel vRPanel2;
    private lbframework.bean.toolBarPadrao.LBToolBarPadrao vRToolBarPadrao1;
    // End of variables declaration//GEN-END:variables
}
